<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta http-equiv="Cache-Control" content="no-transform" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <title>小韦云科技</title>
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <link rel="stylesheet" href="__CSS__/bootstrap.min.css">
    <link rel="stylesheet" href="__CSS__/animate.min.css">
    <link rel="stylesheet" href="__CSS__/style.css">
    <link rel="stylesheet" href="__CSS__/iconfont.css">
</head>

<body id="moar">
{include file="index/_head" /}

<!--end-->
<section class="about sx-jianju text-center" style="padding-bottom: 0;">
    <div class="container">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-10 col-lg-10 col-lg-offset-1 col-md-offset-1">
                <div class="row shuju">
                    <div class="leave-message">
                        <h3>八进制字符转为中文</h3>
                        <div class="flex-justify">
                            <textarea class="dsfss" id="content" cols="30" rows="10" placeholder="请输入八进制字符，如：\344\277\241\346\201\257\344\270\215\345\255\230\345\234\250"></textarea>
                        </div>
                        <div class="flex-justify">
                            <textarea class="dsfss" id="result" cols="30" rows="10" placeholder="转义的结果"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<!--end-->

{include file="index/_footer" /}
</body>

</html>
<script type="text/javascript">
function Octal2Chinese(str) {
  const matches = str.match(/(\\\d{3}){3}/g);
  if (matches) matches.forEach(match => {
    let encoded = '';
    const splits = match.split('\\');
    splits.forEach(code => !code || (encoded += '%' + parseInt(code, 8).toString(16)));
    const cChar = decodeURI(encoded);
    str = str.replace(match, cChar);
  });
  return str;
}
$(document).ready(function(){
    $('#content').keyup(function(){
        var content = $(this).val();
        $('#result').val(Octal2Chinese(content))
    });
});
</script>